<%@ page language="java" isELIgnored="false"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>课程限制管理</title>
<!-- Bootstrap core CSS -->
<link href="/admin/public/bootstrap.min.css" title="" rel="stylesheet" />
<link href="/admin/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" />
<link href="/admin/public/animate.css" rel="stylesheet" />
<link rel="stylesheet" href="/admin/public/inspinia.css" />
<link rel="stylesheet" href="/admin/css/pop-up.css" />
<link rel="stylesheet" href="/admin/css/plugins/toastr/toastr.min.css" />
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
	<script src="/admin/public/html5shiv.min.js"></script>
	<script src="/admin/public/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css"
	href="${request.getContext }/admin/css/xcConfirm.css" />
<script src="/admin/My97/WdatePicker.js"></script>
</head>
<body>
	<div id="wrapper" class="container">
		<div class="wrapper wrapper-content">
			<div class="right_box">
				<div style="border: none; box-shadow: none;" class="right_one row">
					<div class="col-md-12 col-sm-12 col-xs-12" style="float: left;">
						<form class="form-horizontal" method="post" id="courseslimit"
							novalidate="novalidate">
							<input type="hidden" id="limitId" name="limitId" value="${limitId }"/>
							<div class="form-group">
							<c:if test="${limitId==3}">
								<label class="col-lg-2 control-label">会员在课程开始前多少天不能购买？</label>
							</c:if>
							<c:if test="${limitId!=3}">
								<label class="col-lg-2 control-label">会员在课程开始前多少小时不能预约？</label>
							</c:if>
								<div class="col-lg-6">
									<input type="text" class="form-control" id="firstTime"
										name="firstTime" value="${firstTime }" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-9]/g,'')"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">会员在课程开始前多少小时取消预约不予退款？</label>
								<div class="col-lg-6">
									<input onkeyup="value=value.replace(/[^0-9]/g,&#39;&#39;);" type="text" class="form-control" id="lastTime"
										name="lastTime" value="${lastTime }" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-9]/g,'')"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">课程开始前多少小时可以获取二维码？</label>
								<div class="col-lg-6">
									<input type="text" class="form-control" id="getCodeTime"
										name="getCodeTime" value="${getCodeTime }" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-9]/g,'')"/>
								</div>
							</div>
						<div style="${(limitId==1 ||limitId==3)?'':'display:none'  }" >
							<div class="form-group">
								<label class="col-lg-2 control-label">剩余人员比例为多少时课程状态显示紧张？(百分比/%)</label>
								<div class="col-lg-6">
									<input onkeyup="value=value.replace(/[^0-9]/g,&#39;&#39;);" type="text" class="form-control" id="fewMan"
										name="fewMan" value="${fewMan }"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">课程满员时是否允许排队？</label>
								<div class="col-lg-6">
									<select name="queue" id="queue" class="form-control">
			            				<option value="0" ${queue=='0'?'selected':'' }>不允许排队</option>
				    					<option value="1" ${queue=='1'?'selected':'' }>允许排队</option>
		    						</select>
								</div>
							</div>
						</div>
							
							<div style="${limitId==3?'':'display:none'  }" >
							<div class="form-group">
								<label class="col-lg-2 control-label">距训练营开课前多少天退款收取手续费？</label>
								<div class="col-lg-6">
									<input onkeyup="value=value.replace(/[^0-9]/g,&#39;&#39;);" type="text" class="form-control" id="isfei"
										name="isfei" value="${isfei }"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">训练营开课前退款收费比例</label>
								<div class="col-lg-6">
									<input onkeyup="value=value.replace(/[^0-9]/g,&#39;&#39;);" type="text" class="form-control" id="bili"
										name="bili" value="${bili }"/>
								</div>
							</div>
							</div>
							<input type="button" onclick="update();" id="xiugai" style="display: none"/>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script src="/admin/public/jquery-1.11.3.js"></script>
	<script src="/admin/public/bootstrap.min.js" type="text/javascript"></script>
	<script src="${request.getContext }/admin/js/xcConfirm.js"
		type="text/javascript" charset="utf-8"></script>
	<script src="/admin/js/plugins/toastr/toastr.min.js"></script>
	<script src="/admin/js/new_page.js"></script>
	<script>
		function check() {
			var limitId = $("#limitId").val();
			var firstTime = $("#firstTime").val();
			var lastTime = $("#lastTime").val();
			var getCodeTime = $("#getCodeTime").val();
			var fewMan=$("#fewMan").val();
			var queue = $("#queue").val();
			var isfei = $("#isfei").val();
			var bili = $("#bili").val();
			if (firstTime.length == 0) {
				alertNew('会员在课程开始前多少小时不能预约不可为空！', false);
				return false;
			}
			if (lastTime.length == 0) {
				alertNew('会员在课程开始前多少小时不能取消预约！', false);
				return false;
			}
			
			if (getCodeTime.length == 0) {
				alertNew('课程开始前多少小时可以获取二维码不可为空！', false);
				return false;
			}
			if (fewMan.length == 0 && (limitId==3 || limitId==1)) {
				alertNew('剩余多少人时课程状态显示紧张不可为空！', false);
				return false;
			}
			if (queue.length == 0 && (limitId==3 || limitId==1)) {
				alertNew('课程满员时是否允许排队不可为空！', false);
				return false;
			}
			if (isfei.length == 0 && limitId==3) {
				alertNew('距训练营开课前多少天退款收取手续费不可为空！', false);
				return false;
			}
			if (bili.length == 0 && limitId==3) {
				alertNew('训练营开课前退款收费比例不可为空！', false);
				return false;
			}
			return true;
		}
		//修改
		function update() {
			 if (check()) {
				$.ajax({
					type : "post",
					data : $("#courseslimit").serialize(),
					dataType : "json",
					url : "/courses/upodatelimit",
					success : function(data) {
						if (data.success) {
							window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info,{onOk:function(){ 
								$('#ifr', window.parent.document).attr('src',
								'/courses/courseslimit');
					  		}})
						}else{
							alertNew(data.msg, false);
						}
					},
					error : function(data) {
						alert("很抱歉，未知的错误发生了！");
					}
				});
			} 
		}
	</script>
</body>
</html>